function TabItem(label, href) {
	this.label = label;
	this.href = href;
	this.next = null;
}

function InitTabs() {
	top_item = new TabItem("top", "dummy");
	last_item = top_item;
}

function AddTab(label, href) {
	new_item = new TabItem(label, href);
	last_item.next = new_item;
	last_item = new_item;
}

function ShowTabs(current_href) {
	var isInit = false;
	var str = "";
	if (document.getElementById("divTabContainer") == null)
	{
		isInit = true;
		str = "<div id=\"divTabContainer\">";
	}
	str += "<table class=\"tabs\" cellspacing=\"0\">";
	str += "<tr>"
	tab_item = top_item.next;
	count = 0;
	while (tab_item != null) {
		if (tab_item.href == current_href) {
			str += "<td class=\"tab-select-left\"></td>";
			str += "<td class=\"tab-select\">" + tab_item.label + "</td>";
			str += "<td class=\"tab-select-right\"></td>";
			if (IsElement(tab_item.href))
			{
				try{ document.getElementById(tab_item.href).style.display = "block"; }catch(error){}
			}
		}
		else {
			str += "<td class=\"tab-noselect-left\"></td>";
			str += "<td class=\"tab-noselect\">";
			if (IsElement(tab_item.href))
			{
				str += "<a href=\"#\" onclick=\"ShowTabs('"+ tab_item.href +"');return false;\"> "+ tab_item.label +" </a>";
				try{ document.getElementById(tab_item.href).style.display = "none"; }catch(error){}
			}
			else
			{
				str += "<a href=\""+ tab_item.href +"\" > "+ tab_item.label +" </a>";
			}
			str += "</td>";
			str += "<td class=\"tab-noselect-right\"></td>";
		}
		tab_item = tab_item.next;
		count++;
	}
	str += "</tr></table>"; 
	if (isInit)
	{
		str += "</div>"; 
 	    document.write(str);
	}
	else
	{
		document.getElementById("divTabContainer").innerHTML = str;
	}
}

function IsElement(href)
{
	if (href.toUpperCase().indexOf(".HTM")==-1 
		&& href.toUpperCase().indexOf(".JSP")==-1 
		&& href.toUpperCase().indexOf(".DO")==-1 )
	{
		return true;
	}
	else
	{
		return false;
	}
}

InitTabs();
